package Tree;

public class 二叉搜索树的最小绝对差 {
    private int min = Integer.MAX_VALUE;
    private TreeNode pre;

    public int getMinimumDifference(TreeNode root) {
        if (root.left != null) getMinimumDifference(root.left);
        if (pre != null) min = Math.min(min, Math.abs(root.val - pre.val));
        pre = root;
        if (root.right != null) getMinimumDifference(root.right);
        return min;
    }
}
